package http

import (
	"go-monitor/server/g"
	"log"
	"net/http"
)

func init() {
	configCommonRoutes()
}

// StartHTTP 启动HTTP监听
func StartHTTP() {
	if !g.Config().HTTP.Enabled {
		return
	}

	addr := g.Config().HTTP.Listen
	if addr == "" {
		return
	}
	s := &http.Server{
		Addr:           addr,
		MaxHeaderBytes: 1 << 30,
	}
	log.Println("http listening", addr)
	log.Fatalln(s.ListenAndServe())
}
